package games.mapacman.client;

import games.mapacman.common.Constants;

import java.awt.event.KeyEvent;
import java.awt.event.KeyListener;

public class PanelKeyListener implements KeyListener {

	private MaPacman client;

	public PanelKeyListener(MaPacman client) {
		this.client = client;
	}

	public void keyTyped(KeyEvent arg0) {
	}

	public void keyPressed(KeyEvent arg0) {
	}

	public void keyReleased(KeyEvent arg0) {
		switch (arg0.getKeyCode()) {
		case 37:
			client.changeDirection(Constants.DIR_WEST);
			break;
		case 38:
			client.changeDirection(Constants.DIR_NORTH);
			break;
		case 39:
			client.changeDirection(Constants.DIR_EAST);
			break;
		case 40:
			client.changeDirection(Constants.DIR_SOUTH);
			break;
		}

	}

}
